package org.example.listener;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 顺序发送的消息，消费顺序不一定是按照我们发送的顺序来消费的。
 *
 * @author : Charles
 * @date : 2021/6/10
 */
@Slf4j
@Component
@RocketMQMessageListener(
        topic = "random_topic",
        consumerGroup = "random_group")
public class RandomListener implements RocketMQListener<String> {
    @Override
    public void onMessage(String message) {
        //发送消息是顺序发送的0,1,2,3,消费的顺序不一定是顺序的
        log.info("{}收到消息：{}", this.getClass().getSimpleName(), message);
    }
}
